<?php
$content = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"><head>
    <style> 
    body {
        margin: 0;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-size: 13px;
        line-height: 18px;
        color: #333333;
        background-color: #ffffff;
      }
    table {
        max-width: 100%;
        border-collapse: collapse;
        border-spacing: 0;
        }
     .table {
        width: 100%;
        margin-bottom: 18px;
      }
      .table th,.table td {
        padding: 4px;
        line-height: 18px;
        text-align: left;
        vertical-align: top;
        
      }   
        .table th {
          font-weight: bold;
          border-bottom: 1px solid #ddd;
        }
        .table thead th {
          vertical-align: bottom;
        }
        .table thead:first-child tr th, .table thead:first-child tr td {
          border-top: 0;
        }
        .table tbody + tbody {
          border-top: 2px solid #ddd;
        }
        .table-condensed th, .table-condensed td {
          padding: 4px 5px;
        }
        .span6 {
            width: 460px;
          }
          .span7 {
            width: 540px;
          }
        .span8 {
        width: 620px;
        }
        .span9 {
          width: 700px;
        }
        .span10 {
          width: 780px;
        }
        .barras
{
    margin-top: 10px;
}
.verde{
    margin-top: -10px;
    margin-left: -99px;
}
.rojo{
    margin-top: 120px;
    margin-left: -130px
}
.azul{margin-top: -150px;}

    </style>
    </head><body>
    <div id="reportes">
            <p>Fecha del Evento:  <strong>' . $view->evento->getFechaInicial()->format('d-m-Y') . '</strong>  &nbsp; &nbsp; &nbsp;
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  
                <strong>Reporte de Utilidad por evento </strong> <br/>
                Evento: 
                <strong>';
$view->evento->getNombre();
$content .= '</strong>&nbsp; &nbsp; &nbsp; 
                Cliente: 
                <strong>' . $view->cliente->getNombres() . '</strong>
                <br/>
            </p>';
$utilidad = $costoTercero = 0;
foreach($view->detallesXPaquete as $dXpqt): 
    $utilidad += ($dXpqt->getServicio()->getCostoCliente() - $dXpqt->getServicio()->getCosto());
    $costoTercero += $dXpqt->getServicio()->getCosto();
endforeach;
$content .= '<table class="table table-bordered table-striped">
                <tr>
                    <th>Servicio</th>
                    <th>Nombre del Servicio</th>
                    <th>Costo del Servicio</th>
                    <th>Costo a Terceros</th>
                    <th>Utilidad</th>
                </tr>';
               foreach($view->detallesXPaquete as $dXpqt): 
   $content .= '<tr>
                    <td><input type="hidden" value="'.$dXpqt->getCosto().'" id="graphVal_'.$dXpqt->getServicio()->getId().'"/>
                    '.$dXpqt->getServicio()->getId().'</td>';
        $content .= '<td>'.$dXpqt->getServicio()->getDescripcion().'</td>
                    <td>$'.$dXpqt->getServicio()->getCostoCliente().'</td>
                    <td>$'.$dXpqt->getServicio()->getCosto().'</td>
                    <td>$'.($dXpqt->getServicio()->getCostoCliente() - $dXpqt->getServicio()->getCosto()).'</td>
               </tr>';
                endforeach;
$content .='</table>
        <img alt="*" src="./'.$view->urlGraphics.'"/>
        </div>
        <p style="margin-left: 90px">$'.$utilidad .'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $'.$costoTercero.'</p>';
$content .= '</body></html>';
//echo $content;
$dompdf = new DOMPDF();
$dompdf->load_html($content);
$dompdf->render();
$dompdf->stream("Reporte de utilidades.pdf");
